function fig = fm_update(varargin)
% FM_UPDATE create GUI for UDM compiling and system updating messages
%
% HDL = FM_UPDATE()
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Update:    12-Feb-2003
%Update:    22-Feb-2004
%Version:   1.0.3
%
%E-mail:    Federico.Milano@uclm.es
%Web-site:  http://www.uclm.es/area/gsee/Web/Federico
%
% Copyright (C) 2002-2013 Federico Milano

global Theme Fig Settings Comp

if nargin
  switch varargin{1}

   case 'author'

    if ~exist('Fig'), Fig.update = 0, end
    if ~Fig.update
       Fig.update = findobj(get(0,'Children'),'FileName','fm_update');
    end
    poscur = get(Fig.update,'CurrentPoint');
    if poscur(1) > 0.0 && poscur(2) > 0.0 && poscur(1) < 0.05 && poscur(2) < 0.05
        fm_author(3280);
    end

   case 'inspect'

    value = get(findobj(gcf,'Tag','Listbox1'),'Value');
    a = Settings.tviewer;
    switch value
     case 1,  name = ['fm_',lower(Comp.name), '.m'];
     case 3,  name = 'fm_ncomp.m';
     case 4,  name = 'fm_inilf.m';
     case 5,  name = 'fm_var.m';
     case 2,  name = 'comp.ini';
     case 6,  name = 'namevarx.ini';
     case 7,  name = 'fm_dynlf.m';
     case 8,  name = 'fm_dynidx.m';
     case 9,  name = 'Contents.m';
     case 10, name = 'service.ini';
     case 11, name = 'fm_xfirst.m';
     case 12, name = 'psat.m';
     case 13, name = 'closepsat.m';
    end
    %if ~strcmp(name,'fm_.m'), fm_text(13,name), end
    fm_text(13,name)

  end
  return
end

if Fig.update, figure(Fig.update), return, end

h0 = figure('Units','normalized', ...
            'Color',Theme.color01, ...
            'Colormap',[], ...
            'CreateFcn','Fig.update = gcf;', ...
            'DeleteFcn','Fig.update = 0;', ...
            'FileName','fm_update', ...
            'MenuBar','none', ...
            'Name','Update Window', ...
            'NumberTitle','off', ...
            'PaperPosition',[18 180 576 432], ...
            'PaperUnits','points', ...
            'Position',sizefig(0.38,0.40), ...
            'ToolBar','none', ...
            'WindowButtonDownFcn','fm_update author');
h1 = uicontrol('Parent',h0, ...
               'Units','normalized', ...
               'BackgroundColor',Theme.color02, ...
               'ForegroundColor',Theme.color03, ...
               'Position',[0.05  0.05  0.9  0.9], ...
               'Style','frame', ...
               'Tag','Frame1');
h1 = uicontrol('Parent',h0, ...
               'Units','normalized', ...
               'BackgroundColor',Theme.color02, ...
               'FontName',Theme.font01, ...
               'FontSize',12, ...
               'FontWeight','bold', ...
               'ForegroundColor',Theme.color05, ...
               'HorizontalAlignment','left', ...
               'Position',[0.1  0.85  0.8  0.05], ...
               'String','Updating System Files:', ...
               'Style','text', ...
               'Tag','StaticText1');
h1 = uicontrol('Parent',h0, ...
               'Units','normalized', ...
               'BackgroundColor',Theme.color03, ...
               'FontName',Theme.font01, ...
               'ForegroundColor',Theme.color10, ...
               'Position',[0.1  0.25  0.8  0.55], ...
               'Style','listbox', ...
               'Tag','Listbox1', ...
               'Value',1);
% Push buttons
h1 = uicontrol('Parent',h0, ...
               'Units','normalized', ...
               'BackgroundColor',Theme.color03, ...
               'Callback','close(gcf);', ...
               'FontWeight','bold', ...
               'ForegroundColor',Theme.color09, ...
               'Position',[0.7  0.1  0.2  0.1], ...
               'String','Ok', ...
               'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
               'Units','normalized', ...
               'BackgroundColor',Theme.color02, ...
               'Callback','fm_update inspect', ...
               'Position',[0.1  0.1  0.2  0.1], ...
               'String','Inspect File', ...
               'Tag','Pushbutton2');

if nargout > 0, fig = h0; end